package com.github.thinwonton.springboot.showcase.mybatis.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
public class PaymentService {

    @Autowired
    private AccountService accountService;

    @Autowired
    private OrdersService ordersService;

    @Transactional(rollbackFor = Exception.class)
    public void pay(Long accountId, Long orderId, BigDecimal money) {
        accountService.changeMoney(accountId, money);
        ordersService.updateStatus(orderId);
    }

}
